Skip to content

To support jdk 16, add converters and module-info. #1167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 13, 2021

Conversation

mikereiche
Copy link
Collaborator

target 9 is necessary to support module info. module info is necessary to specify the various requires/opens/exports.
Converters for BigInteger and UUID have been added in OtherConverters.
The constructor for MappingCouchbaseConverter has been modified to (1) include the CouchbaseCustomConverters; and (2) specify the SimpleTypes of the converters. Prior to this change, couchbaseMappingContext Bean and mappingCouchbaseConverter Bean in AbstractCouchbaseConfiguration were relied upon for doing this.

Closes #1057.

  • You have read the Spring Data contribution guidelines.
  • There is a ticket in the bug tracker for the project in our JIRA.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

@mikereiche mikereiche requested review from daschl and mp911de August 10, 2021 21:50
@mikereiche mikereiche force-pushed the datacouch_1057_illegal_reflective_access branch from 41981bc to e77d0a3 Compare August 10, 2021 22:04
@mp911de mp911de added the status: blocked An issue that's blocked on an external project change label Aug 12, 2021
@mp911de
Copy link
Member

mp911de commented Aug 12, 2021

For the time being, we cannot include this change as projects are required to remain Java 8-compatible. Setting the release version to 9 produces classes using the Java 9 bytecode version and that is going to break Spring Boot compatibility.

Furthermore, we do not plan to add module descriptors across Spring projects. Once we agree to do so, we will have to make sure to come up with a consistent design for all modules.

@mikereiche
Copy link
Collaborator Author

Mark - I've removed target 9 and the module-info.java. So this just has the added converters and related changes and it does run with jdk 16 without errors.

@mp911de mp911de removed the status: blocked An issue that's blocked on an external project change label Aug 12, 2021
@mp911de
Copy link
Member

mp911de commented Aug 12, 2021

Sounds good. Care to squash all commits into one?

this.setCustomConversions(customConversions);
// if the mappingContext does not have the SimpleTypes, it will not know that they have converters, then it will
// try to access the fields of the type and (maybe) fail with InaccessibleObjectException
((CouchbaseMappingContext) mappingContext).setSimpleTypeHolder(customConversions.getSimpleTypeHolder());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this would work, associating custom conversions should happen outside the converter. Typically, CustomConversions gets configured by users, and then it should get associated with the converter/mapping context within @Bean methods.

Copy link
Collaborator Author

@mikereiche mikereiche Aug 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They were already populated in AbstractCouchbaseConverter.

	protected CustomConversions conversions = new CouchbaseCustomConversions(Collections.emptyList());

I set them again in the MappingCouchbaseConverter constructor so that the mappingContext could capture the SimpleTypes so those converters would be used.

btw - these aren't strictly user-supplied "custom" conversions. These are provided/required by couchbase (and also included in any customer-created CouchbaseCustomConversions).

Maybe the issue is with the MappingCouchbaseConverter constructors - there is no constructor that takes a CouchbaseCustomConverters parameter, therefore the caller cannot capture the SimpleTypes of the CouchbaseCustomsConverts object to populate the mappingContext.

return converters;
}

@WritingConverter public enum UuidToString implements Converter<UUID,String>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please properly format this file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. Fixed in next push.

Optional<BasicCouchbasePersistentEntity<?>> entity = null;
try {
entity = super.addPersistentEntity(typeInformation);
} catch (Exception ioe) {
Copy link
Member

@mp911de mp911de Aug 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That try/catch block shouldn't be here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I've changed the test case that is expecting MappingException to also expect IllegalObjectAccessException.

…:spring-projects/spring-data-couchbase into datacouch_1057_illegal_reflective_access
@mikereiche mikereiche force-pushed the datacouch_1057_illegal_reflective_access branch from abbc1e0 to ec4e237 Compare August 13, 2021 00:55
@mikereiche mikereiche force-pushed the datacouch_1057_illegal_reflective_access branch from dead636 to 93fa907 Compare August 13, 2021 02:02
…:spring-projects/spring-data-couchbase into datacouch_1057_illegal_reflective_access
@mikereiche mikereiche force-pushed the datacouch_1057_illegal_reflective_access branch from 93fa907 to c0beb13 Compare August 13, 2021 03:16
@mikereiche mikereiche merged commit 6512fc0 into main Aug 13, 2021
@mikereiche mikereiche deleted the datacouch_1057_illegal_reflective_access branch September 14, 2021 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Illegal reflective access by org.springframework.util.ReflectionUtils
2 participants